import axios from 'axios'
import { message } from 'antd'
interface axiosConfig {
	baseURL: string
	timeout: number
	contentType?: string
}
const config: axiosConfig = {
	baseURL: '',
	timeout: 5000, // request timeout
}
const service = axios.create(config)
service.interceptors.request.use(
	config => {
		return config
	},
	err => {
		message.error(err)
		return Promise.reject(new Error('请求错误'))
	}
)
service.interceptors.response.use(
	response => {
		return response
	},
	err => {
		message.error(err)
		return Promise.reject(new Error(err))
	}
)
export default service
